﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using WYJCore;
using WYJCore.Extension;
using WYJData.DatabaseAccess;
using WYJWeb;

namespace WYJWeb.Models
{
    /// <summary>
    /// 角色
    /// </summary>
    public class Role : BaseModel, IRole
    {
        /// <summary>
        /// 角色名称
        /// </summary>
        [Column]
        public string Name { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Column]
        public string Note { get; set; }

        /// <summary>
        /// 角色权限
        /// </summary>
        [Column]
        public string Powers { get; set; }
        public List<int> powers => Powers?.SplitToInt();

        public bool HasPower()
        {
            return true;
        }

        public static Dictionary<int, Role> GetAll()
        {
            var db = new Database();
            return db.GetList<Role>().ToDictionary(x => x.Id);
        }

    }
}